package net.gldwork.srcpdr;

import java.util.LinkedList;
import java.util.List;

public class Field {
	private String type;
	private String paramName;
	private String accessModifier;
	private List<String> annotations = new LinkedList<String>();

	public Field(String accessModifier, String type, String paramName) {
		this.type = type;
		this.paramName = paramName;
		this.accessModifier = accessModifier;
	}

	public Field addAnnotation(String anno) {

		if (!annotations.contains(anno)) {
			annotations.add(anno);
		}

		return this;
	}

	public ContentBlock toContentBlock() {
		ContentBlock cb = new ContentBlock();
		for (String anno : annotations) {
			cb.addLine(anno);
		}

		StringBuffer head = new StringBuffer();
		head.append(accessModifier).append(" ").append(type).append(" ")
				.append(paramName).append(";");

		cb.addLine(head.toString());

		return cb;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getParamName() {
		return paramName;
	}

	public void setParamName(String paramName) {
		this.paramName = paramName;
	}

	public String getAccessModifier() {
		return accessModifier;
	}

	public void setAccessModifier(String accessModifier) {
		this.accessModifier = accessModifier;
	}

	public List<String> getAnnotations() {
		return annotations;
	}

	public void setAnnotations(List<String> annotations) {
		this.annotations = annotations;
	}

}
